import {reqGoodDetailInfo} from '@/api'

const actions = {
	async getGoodDetailInfo({commit},skuid){
		const result = await reqGoodDetailInfo(skuid)
		if(result.code === 200){
			commit('SAVE_GOODDETAIL_INFO',result.data)
		}else{
			alert(result.message)
		}
	}
}

const mutations = {
	SAVE_GOODDETAIL_INFO(state,detailInfo){
		state.goodDetailInfo = detailInfo
	}
}

const state = {
	goodDetailInfo:{
		categoryView:{},
		price:0,
		skuInfo:{
			skuImageList:[{imgUrl:''}]
		},
		spuSaleAttrList:[],
		valuesSkuJson:''
	}
}

const getters = {
	categoryView(state){
		return state.goodDetailInfo.categoryView
	},
	skuInfo(state){
		return state.goodDetailInfo.skuInfo
	},
}

export default {
	namespaced:true,
	actions,
	mutations,
	state,
	getters
}